Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PDF features to improve usability #58

Merged
merged 7 commits into from
Apr 13, 2023

Conversation

marcows
Copy link
Contributor

@marcows marcows commented Apr 4, 2023

PDF metadata and PDF outline (navigation in the side bar) have been added.

Tasks:

  • Correct position of PDF outline entry srec_wilson(5)
    It is at the beginning, but should be at the end. Caused by psselect command in page_select.sh (which moves the TOC pages from the end to page 3).
  • Fix the destination position of the PDF outline links
    They are correct for my MSYS2 build, but too far down for my Linux build. They point to around e.g. DESCRIPTION instead of to NAME. Can you reproduce it? Maybe it's just an oddity with my Linux system.
  • Avoid influence of .pdfbookmark for HTML+man generation
    Maybe just enclose it with ".if require_index" as it is done for the .XX macro. Strangely when changing ".nr equire_index 1" (yes, looks like a typo, but seems to be intention) in doc/etc/reference.man to ".nr require_index 1" then the affected TOC entries are missing. I would have expected opposite behaviour.
  • PDF outline only for reference.pdf
    At least in the first step. Currently also README.pdf gets an outline (with only one entry, better to say without the last entry, because of missing .pdfsync command).
  • PDF metadata also for BUILDING.pdf, README.pdf and change_log.pdf

(Partially) implements the second task of #1.

@marcows marcows mentioned this pull request Apr 4, 2023
3 tasks
@marcows
Copy link
Contributor Author

marcows commented Apr 5, 2023

With MSYS2 the PDF is in letter format whereas with Linux it is in A4.
This also applies to the PDFs found in the official releases srecord-1.65.0-win64.zip and srecord-1.65.0-Linux.tar.gz. The PDF from direct website link is the same as from Linux release.

And indeed the paper size has something to do with the wrong destination position.

I changed the paper size via two groff command line options described here:
https://www.gnu.org/software/groff/manual/html_node/Paper-Size.html

Here are my test results, both with MSYS2 and Linux:

groff options outline link destination
-dpaper=a4 -P-pa4 correct, at NAME
-dpaper=letter -P-pletter correct, at NAME
-dpaper=a4 -P-pletter too high up, near start of page
-dpaper=letter -P-pa4 too far down, near DESCRIPTION

Should I set A4 explicitly? Then the problem with link destination would be fixed and the PDFs in Win64 and Linux release files would also be in the same paper size.

@marcows
Copy link
Contributor Author

marcows commented Apr 5, 2023

Rebased on master to modify the new doc/man5/srec_os65a.5

@marcows
Copy link
Contributor Author

marcows commented Apr 6, 2023

Three tasks done with these new five commits. Rebase and cleanup will happen later.

Have to investigate about the wrong placement of srec_wilson(5) PDF outline entry.

@sierrafoxtrot
Copy link
Owner

Should I set A4 explicitly? Then the problem with link destination would be fixed and the PDFs in Win64 and Linux release files would also be in the same paper size.

If this is still an open question, then yes set to A4. This was an oversight on my part when getting the MSYS2 build up and running.

@marcows
Copy link
Contributor Author

marcows commented Apr 7, 2023

If this is still an open question, then yes set to A4.

The latest commit "Explicitly set a consistent paper size" addressed this and set it to A4. But thanks for the reply and agreement.

This was an oversight on my part when getting the MSYS2 build up and running.

The A4/letter inconsistency was already present in the 1.64 release from 2014, I have checked right now.

@sierrafoxtrot
Copy link
Owner

This is looking great Marcus! I'll wait until you hit "ready for review" before I start looking properly (but please don't feel rushed).

Given the number commits, I'm happy to squash but if you'd prefer to rebase into a few select/logical commits, that works too.

@marcows
Copy link
Contributor Author

marcows commented Apr 9, 2023

I'll definitely rebase into a few commits, I'm a clean-history-fanatic.

It's Markus with k, the c just comes from the "cow" part of my username which I'm not a big fan of anymore :-/

@sierrafoxtrot
Copy link
Owner

Sounds good and thank you Markus for correcting me on the spelling. I did take my spelling cue from 'cow" so I'm guessing I'm not the first to make that mistake at least.

marcows added 7 commits April 11, 2023 16:02
Only in doc/man1/srec_license.1 there is no .SH macro, so put it below
.TH (which in most cases is placed directly before .SH anyway).

Preparation for extending the .XX macro to also generate PDF outline
entries additionally to the TOC entries. To get the link target at the
correct position.

This change also has the effect to remove the probably unintended empty
line at each place where this ".if require_index \{ .XX ... .\}"
construct was used, in most cases after the NAME section.

The TOC itself is unchanged in principle, merely line numbers have
changed because of reduced number of pages (due to removed empty lines).
Otherwise it would be wrongly displayed as "[hy]" in the PDF outline.

But it's not even typographically wrong now, see
https://man7.org/linux/man-pages/man7/groff_char.7.html

  For best results in roff systems, use the "-" character in input
  outside an escape sequence only to mean a hyphen, as in the phrase
  "long-term".
Use the "pdfmark" macro package.

The metadata can be viewed via document properties of PDF readers.
Also using the "pdfmark" marco package as for PDF metadata.

The outline can normally be accessed via sidebar of PDF readers.
This is only a recommendation, PDF viewers may ignore this setting.
To be independent of system settings and for a reproducible output
across different systems.

Additionally, inconsistent groff options (e.g. -dpaper=letter -P-pa4),
resulting from implicit configuration, lead to wrong target position of
the PDF outline links.

See also:
https://www.gnu.org/software/groff/manual/html_node/Paper-Size.html

The content in the resulting PDF documents now have a different layout
compared to the latest release (Linux build): It goes further down, but
less far to the right.
Fixes CSpell errors "Unknown word" in the following files:
  doc/CMakeLists.txt
  doc/etc/ref-toc.so
  doc/etc/reference.man

Put "pdfmark" itself to names.txt instead of to the allowed words in
cspell.config.yaml because it is the name of a macro package and "groff"
is listed here as well.
@marcows marcows marked this pull request as ready for review April 11, 2023 14:38
@marcows
Copy link
Contributor Author

marcows commented Apr 11, 2023

Finally ready for review, two notes from my side:

  • The consistent setting of the page size changes the layout (see commit log). If this is undesired, we'd have to investigate how to adjust the page layout with troff. But I'm not really eager to do this ;-)
  • Should "pdfmark" be moved to dictionaries/cmake.txt? I didn't do this because it looked as if only official cmake keywords were included there, but now I don't think that's true anymore. However, I think names.txt is a good place.

@jtxa
Copy link
Contributor

jtxa commented Apr 12, 2023

* Should "pdfmark" be moved to dictionaries/cmake.txt? I didn't do this because it looked as if only official cmake keywords were included there, but now I don't think that's true anymore. However, I think names.txt is a good place.

I created those dictionaries for "non-fixable" words: cmake.txt for CMake stuff (they're all from CMake itself), troff.txt for those I and P prefixed words, and names.txt for any kind of names of people, tools, formats, ...
"pdfmark" would fit best into names.txt.

All other words, which I had not analyzed in detail, are excluded in the top-level cspell.config.yaml. Some words will vanish, when the old release description is reworked.
I'm open for improvements/simplifcations, e.g. perhaps I should rename cmake.txt to code.txt and also add the C, troff, ... keywords.

@sierrafoxtrot sierrafoxtrot self-assigned this Apr 13, 2023
@sierrafoxtrot sierrafoxtrot merged commit 84f1ece into sierrafoxtrot:master Apr 13, 2023
@marcows marcows deleted the pdf-features branch April 13, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants